<template>
	<view class="crystalList-box u-skeleton">
		<u-navbar title="金币记录" :background="{
			'backgroundColor':'#fff'
		}" :is-fixed='true' :borderBottom="false" class="u-skeleton-rect">
		</u-navbar>
		<view class="crystalList u-skeleton-rect">
			<view class="item" v-for="(item,index) in list" :key="index" :style="{
				'background':type == item.type ? '#fff' : '',
				'font-weight':type == item.type ? 'bold' : ''
			}" @click="toSelect(item)">{{item.title}}</view>
		</view>
		<view class="c-content">
			<diy-scorll :Empty='goodsList.length ? false : true' :status = 'status' @scrolltolower='getgoods' @refresherrefresh='refresherrefresh' :is_display = 'goodsList.length'>
				<view class="s-itme" v-for="(item,index) in goodsList" :key="index">
					<view class="left">
						<view class="name">{{item.brief}}</view>
						<view class="time">{{item.create_time}}</view>
					</view>
					<view class="right">{{item.amount}}</view>
				</view>
			</diy-scorll>
		</view>
		<u-skeleton :loading="loding" :animation="true" bgColor="#FFF"></u-skeleton>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				loding: false, //初始化骨架屏展示
				list:[{
					title:'获得记录',
					type:1
				},{
					title:'支出记录',
					type:2
				}],
				type:1,
				//商品列表
				goodsList:[],
				//加载配置
				page:{
					page:1,
					page_size:8,
				},
				//判断刷新出来滚动出现的文字
				status:'loadmore',
			}
		},
		onShow() {
			this.getgoods();
		},
		methods: {
			toSelect(item){
				this.type = item.type;
				this.refresherrefresh();
			},
			// 下拉双薪
			refresherrefresh(callback){
				this.page = {
					page:1,
					page_size:8,
				},
				this.getgoods(callback);
			},
			// 或许商品列表
			getgoods(callback){
				this.$http.asyncSendrequest({
					url:'/profile/giveawayLog',
					data:{
						type:this.type,
						...this.page
					},
					success:res=>{
						if(res.code == '0') {
							if(this.page.page == 1) this.goodsList = [];
							if(res.data.length){
								this.goodsList = this.goodsList.concat(res.data);
								this.page.page += 1;
							} else {
								//下面加载的文字
								this.status = 'nomore'
							}
							if(typeof callback == 'function') callback();
							this.loding = false;
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.crystalList-box {
		min-height: 100vh;
		background: #fff;
		.crystalList{
			margin:0 30rpx 0;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 10rpx;
			background: rgba(0,0,0,.05);
			height: 80rpx;
			border-radius: 80rpx;
			.item{
				width: 48%;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 28rpx;
				border-radius: 60rpx;
			}
		}
		.c-content{
			height: calc(100vh - 230rpx);
			margin-top: 30rpx;
			.s-itme{
				margin: 0 30rpx 30rpx;
				border-radius: 10rpx;
				padding: 30rpx;
				min-height: 150rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.left{
					.name{
						font-size: 26rpx;
						margin-bottom: 20rpx;
					}
					.time{
						font-size: 26rpx;
						color: rgba(0,0,0,.4);
					}
				}
				.right{
					font-size: 28rpx;
					color: red;
					font-weight: bold;
				}

			}
		}
	}
</style>